<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>X-admin v1.0</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/X-admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" method="post" action="" >
            	<input type="hidden" name="id">
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">专业名称</label>
                    <div class="layui-input-inline">
                        <input type="text" id="majorname" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <!-- 为专业添加字段值 -->
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">问题1：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="question1" name="question1" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">问题2：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="question2" name="question2" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">问题3：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="question3" name="question3" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">问题4：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="question4" name="question4" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <button  class="layui-btn" lay-filter="add" lay-submit="">提交</button>
                </div>
            </form>
        </div>
        <script src="__PUBLIC__/X-admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="__PUBLIC__/X-admin/js/x-layui.js" charset="utf-8">
        </script>
        <script>

            layui.use(['form','layer'], function(){
                $ = layui.jquery;
              var form = layui.form();
              layer = layui.layer;

              //监听提交
              form.on('submit(add)', function(data){
                
                console.log(data);

                majorname = $("#majorname").val();
                question1 = $("#question1").val();
                question2 = $("#question2").val();
                question3 = $("#question3").val();
                question4 = $("#question4").val();
                $.post('__MODULE__/Major/insert',{majorname:majorname,question1:question1,question2:question2,question3:question3,question4:question4},function(data){
                    if(data=="添加成功"){
                        // alert("数据增加成功");
                        //加载当前frame
                        // var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        // parent.layer.close(index);
                        // return false;
                        // aaa=1;
                    }else{
                        alert('数据添加失败');
                        return false;
                    }
                });
                layer.alert("添加成功", {icon: 6,time:2000},function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    parent.reload();
                });
                return false;
              });
            }); 
        </script>
    </body>

</html>